package KS;

import java.util.List;
import java.util.Scanner;

public class Shortway {
    public final static int N = Integer.MAX_VALUE;

    public static void SHOW() {
        FloydInGraph graph = new FloydInGraph(10);
        int[][] matrix = {
                {0, N, 40, 80, N, N, N, N, N, N},
                {N, 0, N, 70, 60, N, 20, 20, N, N},
                {40, N, 0, N, 20, 80, N, N, N, N},
                {80, 70, N, 0, 90, N, N, N, N, N},
                {N, 60, 20, 20, 0, N, N, N, N, N},
                {N, N, 80, N, N, 0, 40, N, 10, N},
                {N, 20, N, N, N, 40, 0, 50, N, N},
                {N, 20, N, N, N, N,50, 0, 60, 90},
                {N, N, N, N, N, 10, N, 60, 0, 70},
                {N, N, N, N, N, N, N, 90, 70, 0}};
        Scanner sc = new Scanner(System.in);
        int begin = 0;
        int end = 0;
        int s = 1;
        String x, y;


        System.out.println("有以下城市：北京,武汉,杭州,长沙,重庆,上海,南京,西安,广水,深圳");

        System.out.println("请输入电信抢修队所在城市的位置:");
        x = sc.next();


        switch (x) {
            case "北京":
                begin = 0;
                break;
            case "武汉":
                begin = 1;
                break;
            case "杭州":
                begin = 2;
                break;
            case "长沙":
                begin = 3;
                break;
            case "重庆":
                begin = 4;
                break;
            case "上海":
                begin = 5;
                break;
            case "南京":
                begin = 6;
                break;
            case "西安":
                begin = 7;
                break;
            case "新疆":
                begin = 8;
                break;
            case "广水":
                begin = 9;
                break;
            default:
                System.out.println("没有这个城市或城市名称错误，请重新进入主页");
                  return;
        }


        System.out.println("请输入维护现场所在城市的位置:");
        y = sc.next();
        switch (y) {
            case "北京":
                end = 0;
                break;
            case "武汉":
                end = 1;
                break;
            case "杭州":
                end = 2;
                break;
            case "长沙":
                end = 3;
                break;
            case "重庆":
                end = 4;
                break;
            case "上海":
                end = 5;
                break;
            case "南京":
                end = 6;
                break;
            case "西安":
                end = 7;
                break;
            case "广水":
                end = 8;
                break;
            case "深圳":
                end = 9;
                break;
            default:
                System.out.println("没有这个城市或城市名称错误，请重新进入主页");
                return;
        }
        graph.findCheapestPath(begin, end, matrix);
        List<Integer> list = graph.result;

        System.out.print(String.valueOf(begin).replace("0", "北京").replace("1", "武汉")
                .replace("2", "杭州").replace("3", "长沙").replace("4", "重庆")
                .replace("5", "上海").replace("6", "南京").replace("7", "H")
                .replace("8", "I").replace("9", "J")
                + "市 到 " + String.valueOf(end).replace("0", "北京").replace("1", "武汉")
                .replace("2", "杭州").replace("3", "长沙").replace("4", "重庆")
                .replace("5", "上海").replace("6", "南京").replace("7", "西安")
                .replace("8", "广水").replace("9", "深圳") + "市，最短距离为:");
        System.out.println(graph.dist[begin][end] + " km");
        System.out.println("最佳路径：");
        System.out.println(list.toString().replace("0", "北京").replace("1", "武汉")
                .replace("2", "杭州").replace("3", "长沙").replace("4", "重庆")
                .replace("5", "上海").replace("6", "南京").replace("7", "西安")
                .replace("8", "广水").replace("9", "深圳"));
        System.out.println("----------------------------------------------------------------------------------------------------------");


    }
}